/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export { ApiError } from "./core/ApiError";
export { CancelablePromise, CancelError } from "./core/CancelablePromise";
export { OpenAPI } from "./core/OpenAPI";
export type { OpenAPIConfig } from "./core/OpenAPI";

export type { BaseResponse_boolean_ } from "./models/BaseResponse_boolean_";
export type { BaseResponse_long_ } from "./models/BaseResponse_long_";
export type { BaseResponse_Page_Question_ } from "./models/BaseResponse_Page_Question_";
export type { BaseResponse_Page_QuestionSubmitVO_ } from "./models/BaseResponse_Page_QuestionSubmitVO_";
export type { BaseResponse_Page_QuestionVO_ } from "./models/BaseResponse_Page_QuestionVO_";
export type { BaseResponse_Question_ } from "./models/BaseResponse_Question_";
export type { BaseResponse_QuestionVO_ } from "./models/BaseResponse_QuestionVO_";
export type { DeleteRequest } from "./models/DeleteRequest";
export type { JudgeCase } from "./models/JudgeCase";
export type { JudgeConfig } from "./models/JudgeConfig";
export type { JudgeInfo } from "./models/JudgeInfo";
export { ModelAndView } from "./models/ModelAndView";
export type { OrderItem } from "./models/OrderItem";
export type { Page_Question_ } from "./models/Page_Question_";
export type { Page_QuestionSubmitVO_ } from "./models/Page_QuestionSubmitVO_";
export type { Page_QuestionVO_ } from "./models/Page_QuestionVO_";
export type { Question } from "./models/Question";
export type { QuestionAddRequest } from "./models/QuestionAddRequest";
export type { QuestionEditRequest } from "./models/QuestionEditRequest";
export type { QuestionQueryRequest } from "./models/QuestionQueryRequest";
export type { QuestionSubmit } from "./models/QuestionSubmit";
export type { QuestionSubmitAddRequest } from "./models/QuestionSubmitAddRequest";
export type { QuestionSubmitQueryRequest } from "./models/QuestionSubmitQueryRequest";
export type { QuestionSubmitVO } from "./models/QuestionSubmitVO";
export type { QuestionUpdateRequest } from "./models/QuestionUpdateRequest";
export type { QuestionVO } from "./models/QuestionVO";
export type { UserVO } from "./models/UserVO";
export type { View } from "./models/View";

export { BasicErrorControllerService } from "./services/BasicErrorControllerService";
export { QuestionControllerService } from "./services/QuestionControllerService";
import { interceptors } from "@/interceptor/interceptor";
import store from "@/store";
// 添加请求拦截器
interceptors.request.push({
  onRequest: (config) => {
    console.log("请求拦截器");
    // 添加通用请求头
    config.headers = {
      ...config.headers,
      "x-custom-header": "value",
    };

    // 如果需要添加token
    const token = store.state.user.token;
    if (token) {
      config.headers = {
        ...config.headers,
        Authorization: `${token}`,
      };
    }

    return config;
  },
  onRequestError: (error) => {
    console.error("请求配置错误:", error);
    return Promise.reject(error);
  },
});

// 添加响应拦截器
// 添加响应拦截器
interceptors.response.push({
  onResponse: (result) => {
    console.log("响应拦截器", result);
    // 统一处理响应数据
    if (result.body?.code === 0) {
      return result.body.data; // 直接返回数据部分
    }
    // 处理业务错误
    const errorMessage = result.body?.message || "请求失败";
    //  console.error("业务错误:", errorMessage);
    // throw new Error(errorMessage);
  },
  onResponseError: (error) => {
    // console.error("响应错误:", error);

    // 处理其他HTTP错误
    const errorMessage = error.body?.message || error.message || "网络请求失败";
    // return Promise.reject(new Error(errorMessage));
  },
});
